﻿<c:BaseControl x:Class="personalplaner.gui.stamm.views.PlanStamm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:bs="clr-namespace:personalplaner.business.stamm;assembly=personalplaner.business"
             xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
             xmlns:fac="clr-namespace:personalplaner.gui.stamm.viewmodels.factories"
             vm:ViewModelLoader.FactoryType="{x:Type fac:PlanStammModelFactory}"
             xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
             xmlns:conv="clr-namespace:personalplaner.common.converters;assembly=personalplaner.common"
             xmlns:p="clr-namespace:personalplaner.gui.Properties" 
             Background="Transparent"
             Foreground="#E1000000">

    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/personalplaner.common;component/resources/styles/WhiteStyleTemplates.xaml"/>
                <ResourceDictionary>
                    <conv:DateTimeToIsoConverter x:Key="dateToIso"/>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Border BorderBrush="Transparent" BorderThickness="0" Background="Transparent" Margin="5,5,0,0" Padding="5" >
            <Border.Resources>
                <DataTemplate DataType="{x:Type bs:ArbeitsPlanHeader}">
                    <Grid>
                        <TextBlock x:Name="txt" Text="{Binding Name}" /><!--FontWeight="Heavy"-->
                    </Grid>

                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding Status}" Value="Inactive">
                            <Setter TargetName="txt" Property="Foreground" Value="Red"/>
                        </DataTrigger>
                    </DataTemplate.Triggers>

                </DataTemplate>
            </Border.Resources>
            <ListBox ItemsSource="{Binding ArbeitsPlanList}" SelectedItem="{Binding SelectedArbeitsPlan}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
        </Border>

        <GridSplitter Width="4" Background="Transparent"/>

        <Border BorderBrush="Black" BorderThickness="1,0,0,0" Background="Transparent" Margin="0,10,40,5" Padding="15,0,0,0" Grid.Column="1">

            <Grid Margin="0,0,0,50">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Text="Name" FontWeight="Heavy"/>
                <TextBox DataContext="{Binding SelectedArbeitsPlan}" Text="{Binding Name}" Grid.Column="1"/>

                <TextBlock Text="Zeitraum" Grid.Row="1" FontWeight="Heavy"/>
                <StackPanel DataContext="{Binding SelectedArbeitsPlan}" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" Margin="2,2,0,2">
                    <TextBlock Text="{Binding Von, Converter={StaticResource dateToIso}}"/>
                    <TextBlock Text="-" Margin="5,0,5,0"/>
                    <TextBlock Text="{Binding Bis, Converter={StaticResource dateToIso}}"/>
                </StackPanel>

                <TextBlock Text="Plan Id" Grid.Row="2" FontWeight="Heavy"/>
                <TextBlock DataContext="{Binding SelectedArbeitsPlan}" Text="{Binding PlanId}" Grid.Row="2" Grid.Column="1" Margin="2,2,0,2"/>

                <TextBlock Text="Layout" Grid.Row="3" FontWeight="Heavy"/>
                <TextBlock DataContext="{Binding SelectedArbeitsPlan}" Text="{Binding Layout}" Grid.Row="3" Grid.Column="1" Margin="2,2,0,2"/>

                <Button Command="{Binding EditLayoutCommand}" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0">
                    <TextBlock Text="{x:Static p:Resources.LayoutBearbeiten}" VerticalAlignment="Center" Margin="2"/>
                </Button>
            </Grid>

        </Border>

        <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,20,40,20">
            <Button MinWidth="60" Margin="5" Command="{Binding DeactivateCommand}">
                <TextBlock Text="{x:Static p:Resources.Finalize}"/>
            </Button>
            <Button MinWidth="60" Margin="5" Command="{Binding ReactivateCommand}">
                <TextBlock Text="{x:Static p:Resources.Reactivate}"/>
            </Button>
            <Button MinWidth="60" Margin="5" Command="{Binding DeleteCommand}">
                <TextBlock Text="{x:Static p:Resources.Delete}"/>
            </Button>
            <Button MinWidth="60" Margin="5" Command="{Binding SaveCommand}">
                <TextBlock Text="{x:Static p:Resources.Save}"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsDefault="True" 
                    Command="{Binding OkCommand}">
                <TextBlock Text="{x:Static p:Resources.Ok}"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsCancel="True" 
                    Command="{Binding CancelCommand}">
                <TextBlock Text="{x:Static p:Resources.Cancel}"/>
            </Button>
        </StackPanel>
        
    </Grid>
</c:BaseControl>
